﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using System.Web.Routing;

namespace LynxWebLog.ViewModels
{
    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/LynxBlogAPI.Models")]
    public class PageDataView
    {
        [DataMember]
        public PageData pd { get; set; }
        [DataMember]
        public BlogData bd { get; set; }

        public PageDataView() { }

        public PageDataView(PageData pd, BlogData bd)
        {
            this.pd = pd;
            this.bd = bd;
        }

        public string Url(RequestContext req)
        {

            return string.Format("{0}://{1}{2}/Pages/{3}/{4}/?pgName={5}", req.HttpContext.Request.Url.Scheme,
                    req.HttpContext.Request.Url.Authority, HttpRuntime.AppDomainAppVirtualPath, bd.username, bd.blogname, pd.title);

            //return Path.Combine( string.Format("/Pages/{0}/{1}/{2}", bd.username, bd.blogname, pd.title);
        }
    }
}